cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    onLoad () {
        var freeScroll = this.node.getComponent('FreeScroll');
        freeScroll.loadPage = (page, items, okCbk, noCbk) => this.loadPage(page, items, okCbk, noCbk);
        freeScroll.initItem = (node, data, order) => this.initItem(node, data, order);
        freeScroll.updateItem = (item, data, order) => this.updateItem(item, data, order);
    },

    start() {
        this.node.getComponent('FreeScroll').initView();
    },

    loadPage(page, items, okCbk, noCbk) {
        cc.Linker(URLS.AwardRankMine, {
            page: page,
            pageSize: items,
            value: LINK.gameType
        }).request(okCbk, noCbk);
    },

    initItem(node, data, order) {
        var item = node.getComponent('AwardItem');
        node.cascadeOpacity = false;
        this.updateItem(item, data, order);
        return item;
    },

    updateItem(item, data, order) {
        item.label1.string = data.date.substr(5, data.date.length - 5);
        item.label2.string = data.rank;
        item.label3.string = data.amount;
        item.label4.string = data.awardName;
        item.node.opacity = order % 2 == 0 ? 0 : 255;
    },
});
